home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
swags_z.zip
/
SCROLL.SWG
< prev
next >
Wrap
Text File
|
1993-05-28
|
14KB
|
1 lines
SWAGOLX.EXE (c) 1993 GDSOFT ALL RIGHTS RESERVED 00004 SCREEN SCROLLING ROUTINES 1 05-28-9313:56ALL SWAG SUPPORT TEAM SCROLL1.PAS IMPORT 14 {π>It's just a Fileviewer, I'm working on. I just want to be able toπ>scroll the File up, down, etc.π}ππProgram ScrollDemo;πUsesπ Crt;πTypeπ UpDown = (Up, Down);π { Scroll Text screen up or down. }ππProcedure Scroll({input } Direction : UpDown;π Lines2Scroll,π Rowtop,π RowBot,π ColStart,π ColStop,π FillAttr : Byte);πbeginπ if (Direction = Up) thenπ Asmπ mov ah, 06hπ mov al, Lines2Scrollπ mov bh, FillAttrπ mov ch, Rowtopπ mov cl, ColStartπ mov dh, RowBotπ mov dl, ColStopπ int 10hπ endπ elseπ Asmπ mov ah, 07hπ mov al, Lines2Scrollπ mov bh, FillAttrπ mov ch, Rowtopπ mov cl, ColStartπ mov dh, RowBotπ mov dl, ColStopπ int 10hπ endπend; { Scroll }ππ{ Pause For a key press. }πProcedure Pause;πVarπ chTemp : Char;πbeginπ While KeyPressed doπ chTemp := ReadKey;π Repeat Until(KeyPressed)πend; { Pause }ππVarπ Index : Byte;π stTemp : String[80];πbeginπ ClrScr;π { Display 24 lines of Text. }π For Index := 1 to 24 doπ beginπ stTemp[0] := #80;π fillChar(stTemp[1], length(stTemp), (Index + 64));π Write(stTemp)π end;π { Pause For a key press. }π Pause;π { Scroll Text down by 1 line. Use the Crt's Textattr }π { Variable as the Text color to fill with. }π Scroll(Down, 1, 0, 24, 0, 79, Textattr);π { Pause For a key press. }π Pause;π { Scroll Text up by 1 line. Use the Crt's Textattr }π { Variable as the Text color to fill with. }π Scroll(Up, 1, 0, 24, 0, 79, Textattr);π { Pause For a key press. }π Pauseπend.π 2 05-28-9313:56ALL SWAG SUPPORT TEAM SCROLL2.PAS IMPORT 53 Program Scroll;πUsesπ Crt, Dos;πConstπ Null = #0;π UpArrow = #72;π LeftArrow = #75;π RightArrow = #77;π DownArrow = #80;π PageUp = #73;π PageDown = #81;π ESC = #27;ππTypeπ StrPtr = ^LineBuffer;ππ LineBuffer = Recordπ Line : String[255];π Next : StrPtr;π Prev : StrPtr;π Up23 : StrPtr;π Down23 : StrPtr;π end;πVarπ F : Text;π First,π Last,π Prev,π Current : StrPtr;π Line : Byte;π Row : Byte;ππFunction PadString( S : String ) : String;πVarπ X : Byte;πbeginπ if ord(S[0]) > 79 then S[0]:=Chr(80);π For X := (Length(S) + 1) to 79 Doπ S[X] := ' ';π S[0] := Chr(79);π PadString := S;πend;ππProcedure Normal;πbeginπ TextColor(15);π TextBackGround(0);πend;ππProcedure HighLite;πbeginπ TextColor(10);π TextBackGround(7);πend;ππProcedure AddString;πVarπ S : String;ππbeginπ if First = Nil thenπ beginπ Line := 1;π New(Current);π Current^.Prev := Nil;π Current^.Next := Nil;π Current^.Up23 := Nil;π Current^.Down23 := Nil;π ReadLn(F, S);π Current^.Line := S;π Last := Current;π First := Current;π endπ elseπ beginπ Prev := Current;π New(Current);π Current^.Prev:=Prev;π Current^.Next:=Nil;π ReadLn(F,Current^.Line);π if Line = 23 thenπ beginπ Current^.Up23 := First;π First^.Down23 := Current;π Current^.Down23:= Nil;π endπ elseπ beginπ if Line > 23 thenπ beginπ Current^.Up23 := Prev^.Up23^.Next;π Current^.Up23^.Down23 := Current;π Current^.Down23:=Nil;π endπ elseπ beginπ Current^.Up23:=Nil;π Current^.Down23:=Nil;π end;π end;π Prev^.Next:=Current;π Last:=Current;π if Line<=60 thenπ Line:=Line + 1;π end;πend;ππProcedure DrawScreen( This : StrPtr);πVarπ TRow : Byte;πbeginπ TRow:=1;π While TRow<=23 Doπ beginπ GotoXY(1,TRow);π Write(PadString(This^.Line));π This:=This^.Next;π TRow:=TRow + 1;π end;πend;ππProcedure Scrolling;πVarπ InKey : Char;πbeginπ While (MemAvail>272) and (not Eof(F)) Do AddString;π if not Eof(F) thenπ beginπ GotoXY(1,1);π TextColor(10);π Write('Entire File not Loaded');π end;π Current:=First;π Window(1,1,1,79);π ClrScr;π HighLite;π GotoXY(1,1);π Write(PadString(ParamStr(1)));π Window(2,1,24,80);π Normal;π DrawScreen(First);π Row:=1;π Window(2,1,25,80);π While InKey<>#27 Doπ beginπ InKey:=ReadKey;π Case InKey ofπ Null :π beginπ InKey:=ReadKey;π Case InKey ofπ UpArrow :π beginπ if Current^.Prev = Nil thenπ beginπ Sound(2000);π Delay(50);π NoSound;π endπ elseπ beginπ if Row = 1 thenπ beginπ GotoXY(1,1);π Normal;π Write(PadString(Current^.Line));π GotoXY(1,1);π InsLine;π Current:=Current^.Prev;π HighLite;π Write(PadString(Current^.Line));π endπ elseπ beginπ GotoXY(1,Row);π Normal;π Write(PadString(Current^.Line));π Row:=Row - 1;π GotoXY(1,Row);π HighLite;π Current:=Current^.Prev;π Write(PadString(Current^.Line));π end;π end;π end;ππ DownArrow :π beginπ if Current^.Next = Nil thenπ beginπ Sound(2000);π Delay(50);π NoSound;π endπ elseπ beginπ if Row = 23 thenπ beginπ GotoXY(1,23);π Normal;π Write(PadString(Current^.Line));π GotoXY(1,1);π DelLine;π GotoXY(1,23);π Current:=Current^.Next;π HighLite;π Write(PadString(Current^.Line));π endπ elseπ beginπ GotoXY(1,Row);π Normal;π Write(PadString(Current^.Line));π Row:=Row + 1;π GotoXY(1,Row);π HighLite;π Current:=Current^.Next;π Write(PadString(Current^.Line));π end;π end;π end;ππ PageDown :π beginπ if (Row = 23) and (Current = Last) thenπ beginπ Sound(2000);π Delay(50);π NoSound;π endπ elseπ beginπ Normal;π if Current^.Down23 = Nil thenπ beginπ Current:=Last;π DrawScreen(Last^.Up23);π Row:=23;π GotoXY(1,Row);π HighLite;π Write(PadString(Current^.Line));π endπ elseπ beginπ Current:=Current^.Down23^.Next;π DrawScreen(Current^.Up23);π Row:=23;π GotoXY(1,Row);π HighLite;π Write(PadString(Current^.Line));π end;π end;π end;ππ PageUp :π beginπ if (Row = 23) and (Current^.Up23 = Last) thenπ beginπ Sound(2000);π Delay(50);π NoSound;π endπ elseπ beginπ Normal;π if Current^.Up23 = Nil thenπ beginπ Current:=First;π DrawScreen(First);π Row:=1;π GotoXY(1,Row);π HighLite;π Write(PadString(First^.Line));π endπ elseπ beginπ Current:=Current^.Up23^.Prev;π DrawScreen(Current);π Row:=1;π GotoXY(1,Row);π HighLite;π Write(PadString(Current^.Line));π end;π end;π end;π elseπ beginπ Sound(2000);π Delay(50);π NoSound;π end;ππ end;π end;ππ elseπ beginπ Sound(2000);π Delay(50);π NoSound;π end;ππ end;π end;πend;ππbeginπ if ParamCount < 1 thenπ beginπ WriteLn('Invalid Number of Parameters!!!');π Halt(1);π end;π Assign(F, Paramstr(1));π Reset(F);π Current:=Nil;π First:=Nil;π Scrolling;π GotoXY(1, 23);π WriteLn;π WriteLn;πend.ππ 3 05-28-9313:56ALL SWAG SUPPORT TEAM SCROLL3.PAS IMPORT 33 {π Here is some demo code showing how to use Smooth.Obj. It offersπ vertical and horizontal smooth scrolling in Text or Graphics modes.ππ NOTE: Requires Smooth.Obj (see below) EGA & VGA ONLY !!!!ππ REQUIRES: Smooth.Obj Run the debug script through DEBUG to createπ Smooth.Obj. The NEXT message has the debug script.ππ ALSO: Until last week, I'd never seen a line of Pascal code.π So ForGIVE the rough edges of this code: bear in mindπ the Complete novice status of its author <!!G!!> }ππUses Crt;ππ{ NOTE: SmoothScroll is a MEDIUM MODEL Asm/OBJ For use inπ **either** Pascal or most flavors of modern BASIC.ππ It expects parameters to be passed by reference! We handleπ that here by not including Var, then passing Ofs(parameter).ππ Don't know if this is appropriate, but it works. Comments? }ππ{$F+} Procedure SmoothScroll(Row, Column: Integer); external; {$F-}π{$L Smooth.Obj}ππVarπ Row, Col, Speed, WhichWay : Integer;π Ch : Char;π s : String [60];ππbeginπ TextColor (14); TextBackground (0); ClrScr;ππ GotoXY (25,4); Write ('Press <Escape> to move on.');ππ ch := 'A';π For Row := 10 to 24 doπ beginπ FillChar (s, Sizeof(s), ch);π s[0] := #60; Inc (ch);π GotoXY (10, Row); Write (s);π end;ππ Speed := 1; { Change Speed! See notes. }ππ {The higher the Speed, the faster the scroll.π Use Speed = 1 For subtle scrolling.π Try Speed = 5 (10 in Graphics) For very fast scrolling.π Try Speed = 10+ (25 in gfx) to see some **Real shaking**.ππ Even in Text mode here, Row and Column use GraphICS MODEπ pixel coordinates (ie., begin w/ 0,0). }ππ {================================= demo vertical smooth scrolling}π Row := 0; Col := 0;π WhichWay := Speed; { start by going up }ππ Repeat { press any key to end demo }π GotoXY (2,10); Write (Row, ' ');π SmoothScroll(ofs(Row), ofs(Col));π Row := Row + WhichWay;ππ if (Row > 150) or (Row < 2) then { try 400 here }π WhichWay := WhichWay * -1; { reverse direction }ππ if Row < 1 then Row := 1;ππ Until KeyPressed;ππ ch := ReadKey; Row := 0; Col := 0;π SmoothScroll ( ofs(Row), ofs(Col) ); { return to normal (sort of) }ππ {================================= demo horizontal smooth scrolling}π Row := 0; Col := 0;π WhichWay := Speed; { start by going left }ππ Repeat { press any key to end demo }π GotoXY (38,3); Write (Col, ' ');π SmoothScroll(ofs(Row), ofs(Col));π Col := Col + WhichWay;ππ if (Col > 65) or (Col < 0) then { try 300 here }π WhichWay := WhichWay * -1; { reverse direction }π if Col < 0 then Col := 0;π Until KeyPressed;ππ Row := 0; Col := 0; SmoothScroll(ofs(Row), ofs(Col));πend.ππ{ Capture the following to a File (eg. S.Scr).π then: DEBUG < S.SCR.ππ Debug will create SMOOTH.OBJ.ππ N SMOOTH.OBJπ E 0100 80 0E 00 0C 73 6D 74 68 73 63 72 6C 2E 61 73 6Dπ E 0110 87 96 27 00 00 06 44 47 52 4F 55 50 0D 53 4D 54π E 0120 48 53 43 52 4C 5F 54 45 58 54 04 44 41 54 41 04π E 0130 43 4F 44 45 05 5F 44 41 54 41 90 98 07 00 48 89π E 0140 00 03 05 01 87 98 07 00 48 00 00 06 04 01 0E 9Aπ E 0150 04 00 02 FF 02 5F 90 13 00 00 01 0C 53 4D 4F 4Fπ E 0160 54 48 53 43 52 4F 4C 4C 00 00 00 A7 88 04 00 00π E 0170 A2 01 D1 A0 8D 00 01 00 00 55 8B EC 06 56 33 C0π E 0180 8E C0 8B 76 08 8B 04 33 D2 26 8B 1E 85 04 F7 F3π E 0190 8B D8 8B CA 26 A1 4A 04 D0 E4 F7 E3 8B 76 06 8Bπ E 01A0 1C D1 EB D1 EB D1 EB 03 D8 26 8B 16 63 04 83 C2π E 01B0 06 EC EB 00 A8 08 74 F9 EC EB 00 A8 08 75 F9 26π E 01C0 8B 16 63 04 B0 0D EE 42 8A C3 EE 4A B0 0C EE 42π E 01D0 8A C7 EE 4A 83 C2 06 EC EB 00 A8 08 74 F9 83 EAπ E 01E0 06 B0 08 EE 8A C1 42 EE 83 C2 05 EC BA C0 03 B0π E 01F0 33 EE 8B 76 06 8B 04 24 07 EE 5E 07 8B E5 5D CAπ E 0200 04 00 F5 8A 02 00 00 74π RCXπ 0108π Wπ Qππ'======== end of Debug Script ========π}ππ 4 05-28-9313:56ALL SWAG SUPPORT TEAM SCROLL4.PAS IMPORT 12 {> I need to be able to scroll the Text display in my File viewer,π> both left and right, to allowing reading of lines that extend pastπ> column 80.ππUnFortunately there's no way to scroll horizontally by BIOS or by anotherπservice Function. You have to implement it on your own. Here are two Proceduresπthat I use in my Programs (in Case they must scroll left or right ;-)):π}ππ{$ifNDEF VER70}πConstπ Seg0040 = $0040;π SegB000 = $B000;π SegB800 = $B800;π{$endif}ππTypeπ PageType = Array [1..50,1..80] of Word;ππVarπ Screen : ^PageType;π VideoMode : ^Byte;ππProcedure ScrollRight(X1,Y1,X2,Y2,Attr : Byte);πVarπ Y : Byte;π Attrib : Word;πbeginπ Attrib := Word(Attr SHL 8);π Y := Y1-1;π Repeatπ Inc(Y);π Move(Screen^[Y,X1],Screen^[Y,X1+1],(X2-X1)*2);π Screen^[Y,X1] := Attrib+32;π Until Y=Y2;πend;ππProcedure ScrollLeft(X1,Y1,X2,Y2,Attr : Byte);πVarπ Y : Byte;π Attrib : Word;πbeginπ Attrib := Word(Attr SHL 8);π Y := Y1-1;π Repeatπ Inc(Y);π Move(Screen^[Y,X1+1],Screen^[Y,X1],(X2-X1)*2);π Screen^[Y,X2] := Attrib+32;π Until Y=Y2;πend;ππbeginπ VideoMode := Ptr(Seg0040,$0049);π if VideoMode^=7 thenπ Screen := Ptr(SegB000,$0000)π elseπ Screen := Ptr(SegB800,$0000);πend.ππ{πX1, Y1, X2 and Y2 are the coordinates of the Windows to be scrolled. Attr isπthe color of the vertical line that occurs after scrolling. ;-)π}π